package servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/validateUsername")
public class ValidateUsernameServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("ValidateUsernameServlet.service()");

        response.setContentType("text/plain;charset=utf-8");

        PrintWriter out=response.getWriter();

        String username=request.getParameter("username");

        System.out.println("username = " + username);

        if("abc".equals(username)){
            out.println("用户名已存在");
        }else{
            out.println("用户名可用");
        }

    }
}
